20.1 Writing down the partition function
========================================